Skip to content

feat: replace custom ContextStore with A2A-native task history#121

Open
jezekra1 wants to merge 2 commits intosdk-streaming-refactorfrom
a2a-native-context
Open

feat: replace custom ContextStore with A2A-native task history#121
jezekra1 wants to merge 2 commits intosdk-streaming-refactorfrom
a2a-native-context

Conversation

@jezekra1
Copy link
Copy Markdown
Contributor

Summary

  • Replace the custom ContextStore abstraction with A2A's native TaskStore as the single source of truth for conversation history
  • Implement on_list_tasks in the A2A proxy so the UI can fetch history via ListTasks JSON-RPC
  • Rewire the UI to fetch conversation history from A2A tasks instead of the /contexts/{id}/history REST endpoint
  • Remove ~1,200 lines of duplicate history storage code

This is a breaking change — the context_store parameter, context.store(), and /contexts/history endpoints are all removed.

Closes #116

Changes by layer

adk-server

  • Implement on_list_tasks in ProxyRequestHandler (forwards to agent transport)
  • Remove context history endpoints (POST/GET/DELETE /contexts/{id}/history)
  • Remove title generation job and worker queue
  • Remove history-related service methods, repository code, and schema types
  • Keep context CRUD endpoints for sidebar/metadata

adk-py

  • Delete ContextStore, InMemoryContextStore, PlatformContextStore
  • Rewire RunContext to use TaskStoreload_history() now reads from task_store.get(task_id)
  • Remove store(), store_sync(), delete_history_from_id() from RunContext
  • Remove context_store parameter from create_app() and Server.serve()
  • Remove ContextHistoryItem and history methods from platform SDK
  • Update all agents, examples to remove context.store() calls

adk-ui

  • Add listTasks to A2A JSON-RPC client
  • Create fetchTasksForContext for server-side RSC task fetching
  • Add convertTasksToUIMessages for task→UI message conversion
  • Rewire AgentRunPlatformContextProviderMessagesProvider to use tasks
  • Remove useListContextHistory hook and context history API code

Test plan

  • mise run check passes (linting, type checking, doc snippets)
  • Start adk-server + agent, verify conversation history loads in UI via A2A ListTasks
  • Verify sidebar still lists conversations (contexts endpoint unchanged)
  • Verify canvas edit works (artifact lookup via load_history)
  • Verify new conversations work end-to-end

…eaming support

Adds a delta-based streaming protocol using JSON Patch (RFC 6902) with a
custom `str_ins` operation for efficient token-by-token text delivery.

Server (adk-py):
- MessageAccumulator: 3-level state machine collecting string chunks,
  parts, and metadata into complete messages with incremental patches
- Extended JSON Patch (jsonpatch_ext): str_ins operation for optimized
  text streaming without full-value replacement
- StreamingExtensionServer/Client: extension negotiation, patch
  extraction, delta emission, and graceful fallback for non-streaming
  clients
- Refactored extension base: activation lifecycle, default demand
  constant consolidation (DEFAULT_DEMAND_NAME), and metadata handling
- RunContext: extracted shared store logic into _prepare_store_data,
  added store_sync for synchronous callers
- New yield types: ArtifactChunk for chunked artifact streaming

Client (adk-ts / adk-ui):
- TypeScript streaming extension types and Zod schemas
- UI patch application (streaming.ts): JSON pointer resolution,
  replace/add/str_ins ops with optimized cloning (skip structuredClone
  for primitives)
- Client streaming integration: draft accumulation, patch extraction
  from status update metadata, replace-mode emission
- Fix: text duplication on final message — detect active streaming
  session and emit with replace flag to prevent appending duplicate
  content
- Batched React state updates in AgentRunProvider to reduce re-renders
  during streaming
- Removed dead commented-out proxy header code from adk-client

Tests:
- Unit tests for MessageAccumulator state machine
- Unit tests for extended JSON Patch operations
- Unit tests for RunContext store methods
- E2E streaming tests: patch application, message reconstruction,
  client fallback behavior
- Updated yield tests for new artifact chunking

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Radek Ježek <radek.jezek@ibm.com>
Use A2A Tasks as the single source of truth for conversation history,
eliminating the duplicate ContextStore abstraction.

adk-server:
- Implement on_list_tasks in A2A proxy (forwards to agent transport)
- Remove context history endpoints (POST/GET/DELETE /contexts/{id}/history)
- Remove title generation job and worker
- Remove history-related service, repository, and schema code

adk-py:
- Delete ContextStore, InMemoryContextStore, PlatformContextStore
- Rewire RunContext to use TaskStore (load_history reads from task store)
- Remove store(), store_sync(), delete_history_from_id() from RunContext
- Remove context_store parameter from create_app() and Server.serve()
- Remove ContextHistoryItem and history methods from platform SDK

adk-ui:
- Add listTasks to A2A JSON-RPC client
- Create fetchTasksForContext for server-side task fetching
- Add convertTasksToUIMessages for task-to-UI conversion
- Rewire AgentRun/PlatformContextProvider/MessagesProvider to use tasks
- Remove useListContextHistory, context history API functions and types

Closes #116

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Radek Ježek <radek.jezek@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant